<?php
namespace Home\Controller;
use Common\Controller\CommonController;
class ContactController extends CommonController {
    public function index(){
//     	echo "Hello World";
    	$this->display();
    }
    public function add(){
    	$data['name']=I('name');
    	$data['email']=I('email');
    	$data['tel']=I('tel');
    	$data['message']=I('message');
    	$data['add_time']=time();
    	if(empty($data['name'])){
    		$this->error('请填写您的姓名');
    	}
    	if(empty($data['email'])){
    		$this->error('请填写您的邮箱');
    	}
    	if(!regex($data['email'],"email")){
    		$this->error('请输入正确的邮箱');
    	}
    	if(empty($data['tel'])){
    		$this->error('请填写您的电话');
    	}
    	if(empty($data['message'])){
    		$this->error('请填写您的留言内容');
    	}
    	$list=M('Contact')->add($data);
    	if($list){
    		$this->success('留言成功',U('Index/index'));
    	}else{
    		$this->error('系统繁忙');
    	}
    }
}